﻿<UserControl x:Name="SearchTextBoxControl" x:Class="SynTorrent.SearchTextBox"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:SynTorrent"
             mc:Ignorable="d" Height="30" Width="160" BorderThickness="1.5">

    <UserControl.Resources>
    </UserControl.Resources>
    
    <UserControl.Style>
        <Style TargetType="UserControl" BasedOn="{StaticResource {x:Type UserControl}}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="BorderBrush" Value="{DynamicResource ForegroundBrush}"/>
                </Trigger>
                <Trigger Property="IsMouseOver" Value="False">
                    <Setter Property="BorderBrush" Value="Gray"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Style>
    
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="30"/>
        </Grid.ColumnDefinitions>
        <TextBox x:Name="TextBox" TextWrapping="Wrap" TextChanged="TextBox_TextChanged" KeyDown="TextBox_KeyDown" BorderThickness="0" ToolTip="Type words to filter for">
            <TextBox.Style>
                <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}" xmlns:sys="clr-namespace:System;assembly=mscorlib">
                    <Style.Resources>
                        <VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
                            <VisualBrush.Visual>
                                <Label Content="Filter" Foreground="Gray" />
                            </VisualBrush.Visual>
                        </VisualBrush>
                    </Style.Resources>
                    <Style.Triggers>
                        <Trigger Property="Text" Value="{x:Static sys:String.Empty}">
                            <Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
                        </Trigger>
                        <Trigger Property="Text" Value="{x:Null}">
                            <Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </TextBox.Style>
        </TextBox>
        <Button x:Name="ClearButton" Style="{DynamicResource SimpleButton}" Click="ClearButton_Click" MinWidth="10" Grid.Column="1" FontWeight="Bold" Foreground="{x:Null}" Background="{x:Null}" BorderThickness="0" ToolTip="Clear filter.">
            <StackPanel>
                <Image Source="Images/ClearButton.ico" Height="10"/>
            </StackPanel>
        </Button>
    </Grid>
</UserControl>
